package com.polytech.diploma.SQLGenerator.Oracle.Arguments;

import java.text.SimpleDateFormat;

public enum DataType {
	
	/**
	 * Oracle Internal Data Types
	 */
	VARCHAR2,
	CHAR,
	NUMBER,
	LONG,
	BINARY_FLOAT,
	BINARY_DOUBLE,
	DATE,
	TIMESTAMP,
	TIMESTAMP_WITH_TIME_ZONE,
	TIMESTAMP_WITH_LOCAL_TIME_ZONE,
	INTERVAL_YEAR_TO_MONTH,
	INTERVAL_DAY_TO_SECOND,
	RAW,
	LONG_RAW,
	REF,	
	ROWID,
	UROWID,
	BLOB,
	CLOB,
	NCLOB,
	BFILE;
	
	public static DataType defineType(String value)
	{
		try {
			Double.parseDouble(value);
			return NUMBER;
		} catch (Exception e) {
			try {
				SimpleDateFormat sdf = new SimpleDateFormat();
				sdf.parse(value);
				return DATE;
			} catch (Exception e1) {
				return VARCHAR2;
			}			
		}
	}
}
